﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;

namespace IHISCETeim.Web.MachineSys.FTradeModel
{
    public partial class AddAdjustingPageStep2 : PageBase
    {
        #region 属性 (查询条件)

      

        protected string JiHao
        {
            get
            {
                return GetRequestValue<string>("JiHao", "");

            }
        }

        protected int FCatheringId
        {
            get
            {
                return GetRequestValue<int>("FCatheringId", 0);

            }
        }

        protected string JingXiaoShang
        {
            get
            {
                return GetRequestValue<string>("JingXiaoShang","");
            }
        }
        /// <summary>
        /// --2013 4 15 取消
        /// </summary>
        /// <returns></returns>
        protected string GetFTradeCatheringByJingXiaoShang()
        {
            List<FTradeCatheringInfo> list = FTradeCatheringController.GetByJingXiaoShang(JingXiaoShang, "'已冲完','未冲完'");
            StringBuilder sb = new StringBuilder();
            sb.AppendFormat("<option value=\"{0}\" {2}>{1}</option>","0","请选择...",FCatheringId==0?"selected":"");
            foreach (FTradeCatheringInfo itm in list)
            {
                sb.AppendFormat("<option value=\"{0}\" {2}>{1}</option>", itm.FCatheringId, itm.FCTitle, itm.FCatheringId == FCatheringId ? "selected" : "");
            }

            return sb.ToString();
        }
        #endregion


        protected void Page_Load(object sender, EventArgs e)
        {
            //if(GetRequestValue<string>("ajax","")=="query")
                DataBind();
        }

        protected override string orderField
        {
            get
            {
                return string.IsNullOrEmpty(base.orderField) ? "CreateDate" : base.orderField;
            }
        }
        protected override string orderDirection
        {
            get
            {
                return string.IsNullOrEmpty(base.orderDirection) ? "DESC" : base.orderDirection;
            }
        }
        protected void DataBind()
        {
            this.rpMenu.DataSource = FTradeBalanceController.GetAddAdjustingList(GetSQLWhere(), pageNum, numPerPage, SQLSort,ref TotalCount);
            this.rpMenu.DataBind();
           
        }
        protected string GetSQLWhere()
        {
            string wheresql = "";
            string sqlcommonFiled = "";

            if (!string.IsNullOrEmpty(JiHao))
            {
                sqlcommonFiled = QueryOperatorsEnumHelper.ConvertCommonOperator("JiHao", QueryOperatorsEnum.包含, JiHao);
                wheresql = sqlcommonFiled;
            }



            if (FCatheringId>0)
            {
                string DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("FCatheringId", QueryOperatorsEnum.等于, FCatheringId.ToString());
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + DOWNSQL;
                }
                else
                {
                    wheresql = DOWNSQL;
                }
            }
            if (JingXiaoShang!="")
            {
                string DOWNSQL = QueryOperatorsEnumHelper.ConvertCommonOperator("JingXiaoShang", QueryOperatorsEnum.等于, JingXiaoShang.ToString());
                if (!string.IsNullOrEmpty(wheresql))
                {
                    wheresql += " and " + DOWNSQL;
                }
                else
                {
                    wheresql = DOWNSQL;
                }
            }
         

            return wheresql;
        }
        protected override string DWZRef
        {
            get { return ""; }
        }
    }
}